﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WS1.Models;
using WS1.Repository;

namespace WS1.Services
{
	public class ProductsServices:IDisposable
	{
        private readonly ProductsRepository _productsRepository;

        public ProductsServices()
        {
            _productsRepository = new ProductsRepository();
        }

        public IEnumerable<Products> GetAll()
        {
            return _productsRepository.All();
        }
        public Products Get(int id)
        {
            return _productsRepository.Single(id);
        }
        public bool Add(Products product)
        {
            return _productsRepository.Add(product);
        }
        public bool Update(int id, Products product)
        {
            return _productsRepository.Update(id, product);
        }
        public bool Remove(int id)
        {
            return _productsRepository.RemoveSingle(id);
        }
        public void Dispose()
        {
            _productsRepository.Dispose();
        }
    }
}